import logging
from redis import StrictRedis


class Config():
    """配置信息"""
    SECRET_KEY = 'DASKDJANDSJNAJ'

    # 数据库的配置信息
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/sanlang"
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # redis配置
    REDIS_HOST = '127.0.0.1'
    REDIS_POST = 6379

    # flask_session的配置信息
    SESSION_TYPE = 'redis'  # 指定session保存到redis
    SESSION_USE_SIGNER = True  # 加密签名处理
    # 使用redis保存session
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_POST)
    PERMANENT_SESSION_LIFETIME = 86400 * 2  # session的有效期2天

    # 默认日志等级
    LOG_LEVEL = logging.DEBUG


class DevelopmentConfig(Config):
    """开发模式下的配置"""
    DEBUG = True


class ProductionConfig(Config):
    """生产模式下的配置"""
    DEBUG = True
    LOG_LEVEL = logging.ERROR


class TestingConfig(Config):
    """单元测试模式下的配置"""
    DEBUG = True

config = {
    "developmentconfig": DevelopmentConfig,
    "productionconfig": ProductionConfig,
    "testingconfig": TestingConfig
}